<extend name="Public/base" />
<block name="body">
    <form action="" method="POST" id="form1" onkeydown="if(event.keyCode==13)return false;" class="row" style="margin-left: 0px;margin-top:5px;">
        <div class="main-title">
            <h2>客户数据</h2>
            <a class="btn btn-default" id="exportBtn">导出</a>
        </div>
        <div class="cf">
            <div class=" fl cf">
                <div class="sleft">
                    <a class="sch-btn btn btn-success searchbtn" href="javascript:;"  url="{:U('data?flag')}">总消费排序↓</a>
                    <a class="sch-btn btn btn-success searchbtn" style="margin-left: 20px;" href="javascript:;"   url="{:U('data?flag=count')}">订单量排序↓</a>
                </div>
            </div>
            <!-- 高级搜索 -->
            <div class="search-form fr cf">
                <div class="sleft">
                    <input type="text" class="search-input" name="realName" value="{:I('realName')}" placeholder="请输入客户姓名">
                    <a class="sch-btn" href="javascript:;" id="search" url="{:U('data')}"><i class="btn-search"></i></a>
                </div>
            </div>
        </div>
        <div class="data-table table-striped">
            <table class="table table-hover">
                <thead class="" style="color:#FFF;">
                    <tr>

                        <th class="" style="background: #353535;line-height: 40px;">客  户</th>
                        <th class="" style="background: #353535;line-height: 40px;">总消费</th>
                        <th class="" style="background: #353535;line-height: 40px;">退货金额</th>
                        <th class="" style="background: #353535;line-height: 40px;">总订单</th>
                        <th class="" style="background: #353535;line-height: 40px;">首次下单</th>
                    </tr>
                </thead>
                <tbody>
                <volist name="buyers" id="buyer">
                    <tr class="" style="margin-top: 3px;background: none;border: none;">
                        <td class="" data-name="{$buyer.realName}" style="border: 1px solid #30333F;">{$buyer.toName}</td>
                        <td class="" style="border: 1px solid #30333F;">{$buyer.sum|number_format}</td>
                        <td class="" style="border: 1px solid #30333F;">{$buyer.rejectData|number_format}</td>
                        <td class="" style="border: 1px solid #30333F;">{$buyer.count}</td>
                        <td class="" style="border: 1px solid #30333F;">{$buyer.firstDate|time_format=###,'Y-m-d'}</td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>

    </form>
</block>
<block name="script">
    <script>
        $(".searchbtn").click(function () {
            if(confirm("该操作非常地消耗服务器资源,继续查询？")){

            }else{
                return false;
            };

        });
        $("#search").click(function(){
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            var queryselect = $('.search-form').find('select').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            queryselect = queryselect.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            queryselect = queryselect.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
                url += '&' + queryselect;
            } else {
                url += '?' + query;
                url += '?' + queryselect;
            }
            window.location.href = url;
        })
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        $("#submitForm").click(function(){
            $("#form1").submit();
        });
        $("#exportBtn").click(function(){
            window.location.href = window.location.href+'&export=1';
        })
    </script>
</block>
